package com.data.modules.online.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.data.modules.online.auth.entity.OnlAuthRelation;
import com.data.modules.online.auth.mapper.OnlAuthRelationMapper;
import com.data.modules.online.auth.service.IOnlAuthRelationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

@Slf4j
@SuppressWarnings("ALL")
@Service
public class OnlAuthRelationServiceImpl extends ServiceImpl<OnlAuthRelationMapper, OnlAuthRelation> implements IOnlAuthRelationService {

    @Override
    public void saveRoleAuth(String roleId, String cgformId, int type, String authMode, List<String> authIds) {
        LambdaQueryWrapper<OnlAuthRelation> var6 = new LambdaQueryWrapper<OnlAuthRelation>();
        var6.eq(OnlAuthRelation::getCgformId, cgformId);
        var6.eq(OnlAuthRelation::getType, type);
        var6.eq(OnlAuthRelation::getAuthMode, authMode);
        var6.eq(OnlAuthRelation::getRoleId, roleId);
        ((OnlAuthRelationMapper)this.baseMapper).delete(var6);
        ArrayList var7 = new ArrayList();
        Iterator var8 = authIds.iterator();

        while(var8.hasNext()) {
            String var9 = (String)var8.next();
            OnlAuthRelation var10 = new OnlAuthRelation();
            var10.setAuthId(var9);
            var10.setCgformId(cgformId);
            var10.setRoleId(roleId);
            var10.setType(type);
            var10.setAuthMode(authMode);
            var7.add(var10);
        }

        this.saveBatch(var7);
    }
}
